package com.wobito.common.interceptor;


import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
import org.apache.ibatis.executor.statement.StatementHandler;

import java.sql.Connection;

/**
 * @Author: lambyang
 * @CreateTime: 2024-09-23
 * @Description: SQL自定义拦截器
 * @Version: 1.0
 */
public class CustomBlockAttackInnerInterceptor extends BlockAttackInnerInterceptor {

    @Override
    public void beforePrepare(StatementHandler sh, Connection connection, Integer transactionTimeout) {
        String sql = sh.getBoundSql().getSql().trim().toLowerCase();

        // 允许 CREATE TABLE 语句
        if (sql.startsWith("create table")) {
            return;
        }

        // 对于其他语句，使用默认的拦截逻辑
        super.beforePrepare(sh, connection, transactionTimeout);
    }
}
